<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="static/layui/css/layui.css" />
    <script type="text/javascript" src="static/layui/layui.js" ></script>
    <script type="text/javascript" src="static/js/jquery.min.js" ></script>
    <title>用户更新</title>
    <script type="text/javascript" >
        $(function () {
            //获取请求参数id
            var url=window.location.href;
            //同过截取发过来的url地址来得到oid
            var oid=url.substring(url.indexOf('oid')+4)
            //赋值
            $("#oid").val(oid);
            //ajax 根据oid查询数据
            $.ajax({
                url:'/house/getOrder',
                data:{"oid":oid},
                type:'post',
                dataType:'json',
                cache:false,
                success:function (obj) {
                    //赋值
                    $("#oid").val(oid);
                    $("#cname").val(obj.cname);
                    $("#picture").val(obj.picture);
                    $("#houseType").val(obj.houseType);
                    $("#price").val(obj.price);
                    $("#area").val(obj.area);
                    $("#position").val(obj.position);
                }
            })
        });
    </script>
</head>
<body>
<form class="layui-form"  id="form2">
    <input type="hidden" name="oid"  id="oid" placeholder="订单号" autocomplete="off" class="layui-input"/>

    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="cname"  id="cname" placeholder="请输入客户姓名" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
            <input type="text" name="picture"  id="picture" placeholder="请输入图片地址" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房型</label>
        <div class="layui-input-block">
            <input type="text" name="houseType"  id="houseType" placeholder="请输入房型" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block">
            <input type="text" name="price"  id="price"  placeholder="请输入价格" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">面积</label>
        <div class="layui-input-block">
            <input type="text" name="area"  id="area" placeholder="请输入面积大小" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input name="position" id="position" placeholder="请输入地址" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo"> 确定修改</button>
            <button class="layui-btn" > <a href="order.html">放弃修改</a></button>
        </div>
    </div>
</form>
<script>
    layui.use(['form','layer'],function(){
        var form=layui.form,layer=layui.layer;
        //监听提交
        form.on('submit(formDemo)',function(data){
            $.ajax({
                url:'/house/toOrderUpdate',
                data:$("#form2").serialize(),//序列化表单，直接获取表单中的所有值
                type:'post',
                dataType:'json',
                cache:false,
                success:function(obj){
                    if(obj.code==0){
                        layer.msg("修改成功",{icon:6});
                        //  window.parent.location.href="userList.html";
                        window.location.href="order.html";
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>
</body>
</html>